﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

namespace MyFloridaHouse.DataAccess
{
    public partial class DAL_CensusData
    {

        /// <summary>
        /// Gets the ACS (American Community Survey) dictionaryIds list.
        /// </summary>
        /// <param name="iTableIDList">The itableID list.</param>
        /// <returns>List of strings.</returns>
        /// <remarks>SPROC: usp_GetACSDictionaryIDs</remarks>
        public List<string> GetACSDictionaryIDs(string iTableIDList)
        {
            List<string> itemList = new List<string>();

            //string storedProcedureName = "usp_GetACSDictionaryIDs";
            string storedProcedureName = "usp_tl10GetACSDictionaryIDs10";

            using (SqlConnection db = Connect())
            {
                SqlCommand StoredProcedureCommand = new SqlCommand(storedProcedureName, db);
                StoredProcedureCommand.CommandType = CommandType.StoredProcedure;
                SqlParameter dataPartIDParm = StoredProcedureCommand.Parameters.AddWithValue("iTableIDList", iTableIDList);
                dataPartIDParm.Direction = ParameterDirection.Input;

                db.Open();
                using (SqlDataReader rdr = StoredProcedureCommand.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        itemList.Add(rdr.GetString(0));
                    }
                }
            }

            //Database db = Connect();
            ////DbCommand dbCommand = db.GetStoredProcCommand("usp_GetACSDictionaryIDs");
            //DbCommand dbCommand = db.GetStoredProcCommand("usp_tl10GetACSDictionaryIDs10");
            //db.AddInParameter(dbCommand, "iTableIDList", DbType.String, iTableIDList);
            //dbCommand.CommandTimeout = 60000;
            //using (IDataReader rdr = db.ExecuteReader(dbCommand))
            //{
            //    while (rdr.Read())
            //    {
            //        itemList.Add(rdr.GetString(0));
            //    }
            //}
            return itemList;
        }
    }
}
